<template>
	<view>
		<u-navbar title="添加USDT" :titleStyle="{ color: '#fff' }" leftIconColor="#fff" leftIconSize="40" :autoBack="true"
			bgColor="#181f2f"></u-navbar>
		<view class="f_content">
			<view class="ul">
				
				<div class="item" >
							<div class="title">选择网络</div>
					</div>
					<div class="tabs" >
						<div :class="tabid == 1 ? 'xuanzhong onetab' : 'wxuanzhong onetab'" @click="taptab(1)">ERC20</div>
						<div :class="tabid == 2 ? 'xuanzhong onetab' : 'wxuanzhong onetab'" @click="taptab(2)">TRC20</div>
						<!--div :class="tabid == 3 ? 'xuanzhong onetab' : 'wxuanzhong onetab'" @click="taptab(3)">OMNI</div-->
					</div>


				<view class="li">
					<label>姓名</label>
					<view class="input-box">
						<input type="text" v-model="form.name" placeholder="输入姓名" />
					</view>
				</view>
				
				<view class="li">
					<label>USDT地址</label>
					<view class="input-box">
						<input type="text" v-model="form.account" oncut="return false" onpaste="return false" oncopy="return false" placeholder="输入USDT地址" />
					</view>
				</view>
			</view>
			<view class="sure">
				<button @click="postAddCard">确认</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		bankCard,
		addCard,
	} from '@/config/api.js'
	export default {
		data() {
			return {
					tabid: 1,
				form: {
					uid: uni.getStorageSync('uid'), // uid
					name: '', // 姓名
					bank: '', // 所属银行
					area: '', // 开户行
					account: '', // 卡号
					type:'USDT',
					link:'ERC20'
				}

			};
		},
		methods: {
			taptab(id) {
						this.tabid = id;
						if(id==1){
							this.link='ERC20'
						}else{
								this.link='TRC20'
						}
					},
			postAddCard() {
					bankCard({
						uid: uni.getStorageSync('uid')
					}).then(res => {
						console.log('bankCard', res);
						if(res.data.banks.length<1){
							addCard(this.form).then(res => {
								console.log('addCard', res);
								uni.$u.toast(res.info)
								setTimeout(() => {
									this.$Router.pushTab('/pages/mine/mine')
								}, 2000)
							}).catch(err => {
								console.log('err: ', err)
							})
						}else{
							this.$u.toast('银行卡绑定超过上限')
						}
					}).catch(err => {
						console.log('err: ', err)
					})
			}
		}
	};
</script>

<style scoped lang="scss">
	.tabs {
				padding: 10px;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: flex-start;
				.onetab {
					padding: 10px 25px;
					border-radius: 5px;
					font-size: 14px;
					margin-right: 20px;
				}
				.xuanzhong {
					background-color: #edd33a;
					color: #fff;
				}
				.wxuanzhong {
					background-color: #ffffff;
					color: #333;
				}
			}
	.f_content {
		width: 100%;
		height: 100%;
		margin-top: 40px;
		overflow: scroll;
		-webkit-overflow-scrolling: touch;

		.ul {
			margin: 40rpx;
			display: flex;
			flex-direction: column;

			.li {
				display: flex;
				flex-direction: row;
				text-align: left;
				height: 92rpx;
				line-height: 92rpx;
				border-bottom: 1px solid #111;
				position: relative;

				label {
					flex: 2;
				}

				.input-box {
					flex: 4;
					position: relative;

					input {
						background: none;
						color: #fff;
						font-size: 14px;
						height: 100%;
					}
				}
			}
		}

		.sure {
			height: 162rpx;
			margin-top: 28rpx;
			position: relative;

			button {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -50%);
				margin: 0 auto;
				width: 90%;
				height: 50%;
				font-size: 16px;
				border-radius: 13rpx;
				background-color: #edd33a;
				color: #333;
				border: 0 none;
			}
		}
	}
</style>
